﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ITAP.ContourBuilder.Components;

namespace ITAP.ContourBuilder.Manipulation.Tolerance
{
    public class ToleranceManager : IContourVisitor
    {
        private bool enabled = true;

        public bool Enabled
        {
            get { return enabled; }
            set { enabled = value; }
        }

        #region IContourVisitor Members

        public void Visit(ContourModel model)
        {
            throw new NotImplementedException();
        }

        public void Visit(ContourContainer container)
        {
            IEnumerable<IContourComponent> allInnerComponents = container.GetAllInnerComponents();
            foreach (IContourComponent innerComponent in allInnerComponents)
                innerComponent.ComponentsInTolerance.Clear();

            foreach (IContourComponent innerComponent1 in allInnerComponents)
            {
                if (this.enabled)
                {
                    foreach (IContourComponent innerComponent2 in allInnerComponents)
                    {
                        if (innerComponent1 != innerComponent2)
                            innerComponent1.AcceptVisitor(innerComponent2);
                    }
                }
                else
                {
                    innerComponent1.AcceptVisitor(this);
                }
            }
        }

        public void Visit(ContourElement element)
        {
            //throw new NotImplementedException();
        }

        public void Visit(ContourConnector connector)
        {
            //throw new NotImplementedException();
        }

        #endregion

        #region IContourVisitor Members


        public void Visit(ContourElementHook hook)
        {
            //throw new NotImplementedException();
        }

        #endregion

        #region IContourVisitor Members


        public void Visit(ContourText text)
        {
            //throw new NotImplementedException();
        }

        #endregion

        #region IContourVisitor Members


        public void Visit(ContourCommentLine commentLine)
        {
            //throw new NotImplementedException();
        }

        #endregion

        #region IContourVisitor Members


        public void Visit(ITAP.ContourBuilder.Components.Dimensions.Dimension dimension)
        {
            //throw new NotImplementedException();
        }

        #endregion

        #region IContourVisitor Members


        public void Visit(ContourHole hole)
        {
          //  throw new NotImplementedException();
        }

        #endregion
    }
}
